package Q414

import java.util.TreeSet


/**
 * 第三大的数
 * @author 2377
 * @date 2022.5.10
 */
fun main(){

}

class Solution {
    fun thirdMax(nums: IntArray): Int {
        val s = TreeSet<Any>()
        for (i in nums.indices) {
            s.add(nums[i])
        }
//        val o: Array<Any> = s.toTypedArray()
        var o = s.toTypedArray()
        return if (s.size < 3) {
            o[o.size - 1] as Int
        } else o[o.size - 3] as Int
    }
}

